home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Graphics / Utility / GL Viewer 1.1.1 / src ƒ / macinit.c < prev    next >
C/C++ Source or Header  |  1993-08-25  |  5KB  |  203 lines

  1. /*
  2.   macmain.c
  3.     -- Macintosh initializations, then call real main
  4.  
  5. //Note: compile this segment as Main for generic 68000 processor, so it won't
  6. // fail on generic mac
  7.  
  8. */
  9.  
  10.  
  11. #pragma segment Main
  12.  
  13. #include <Palette.h>
  14. #include <console.h>
  15. #include "grasp.h"
  16. #include "procImage.h"
  17. #include "macPrefs.h"
  18.  
  19.  
  20. static void    InitMac (void);
  21. extern void InitExec (void);
  22.  
  23.  
  24. //#define    VERSION            curSysEnvVers
  25. #define    nocolorID        130
  26. #define    no68020            133
  27. #define    no68881            132
  28. #define    no256              134
  29. #define    nosys6            135
  30.  
  31.  
  32.     static void
  33. MacInit (void)
  34.  
  35. {
  36.     SysEnvRec        theWorld;
  37.     OSErr                OSys;
  38.     DialogPtr        crashDia;
  39.     long                tick;
  40.  
  41.  
  42.     cshow (stdin);
  43.     console_options.pause_atexit = 0;
  44.  
  45.     InitMac ();
  46.     InitExec ();
  47.  
  48. /*______________________________________________________*/
  49. /*            If not right Machine then stop            */
  50. /*______________________________________________________*/
  51.     OSys = SysEnvirons( curSysEnvVers,&theWorld);
  52.     if(!theWorld.hasColorQD) {
  53.         crashDia = GetNewDialog (nocolorID, nil, (WindowPtr) -1);
  54.         DrawDialog (crashDia);
  55.         Delay (300, &tick);
  56.         ExitToShell();
  57.         }
  58.     if(theWorld.processor < env68020) {
  59.         crashDia = GetNewDialog (no68020, nil, (WindowPtr) -1);
  60.         DrawDialog (crashDia);
  61.         Delay (300, &tick);
  62.         ExitToShell();
  63.         }
  64.     /*if(!theWorld.hasFPU) {
  65.         crashDia = GetNewDialog (no68881, nil, (WindowPtr) -1);
  66.         DrawDialog (crashDia);
  67.         Delay (300, &tick);
  68.         ExitToShell();
  69.         }
  70.     if(theWorld.systemVersion < 0x0600) {
  71.         crashDia = GetNewDialog (nosys6, nil, (WindowPtr) -1);
  72.         DrawDialog (crashDia);
  73.         Delay (300, &tick);
  74.         ExitToShell();
  75.         }*/
  76.  
  77. #ifdef UnDeFineD
  78. /*______________________________________________________*/
  79. /*                     Set Rects                        */
  80. /*______________________________________________________*/
  81.     screenRect = qd.screenBits.bounds;
  82.     offLeft = 0;
  83.     offTop = 0;
  84.     offRight = screenRect.right;
  85.     offBottom = screenRect.bottom;
  86.     SetRect(&BaseRect, 40, 60, 472, 282);
  87.     tempRgn = GetGrayRgn();
  88.     HLock ((Handle) tempRgn);
  89.     TotalRect = (**tempRgn).rgnBBox;
  90.     SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40,
  91.                 (**tempRgn).rgnBBox.bottom - 40);
  92.     HUnlock ((Handle) tempRgn);
  93.  
  94. /*______________________________________________________*/
  95. /*        Open Window & set Palette & Picture           */
  96. /*______________________________________________________*/
  97.     theGDevice = GetMainDevice();
  98.     HLock ((Handle) theGDevice);
  99.     mycolors = (**(**theGDevice).gdPMap).pmTable;
  100.     numcolor = (**(**theGDevice).gdPMap).pixelSize;
  101.  
  102.     HUnlock((Handle) theGDevice);
  103.  
  104.     switch (numcolor) {
  105.         case 1:
  106.             numcolor = 2;
  107.             break;
  108.         case 2:
  109.             numcolor = 4;
  110.             break;
  111.         case 4:
  112.             numcolor = 16;
  113.             break;
  114.         case 8:
  115.             numcolor = 256;
  116.             break;
  117.         }
  118.     
  119.     myWindow = NewCWindow(nil, &BaseRect, "\p", TRUE, zoomDocProc,
  120.                             (WindowPtr) -1, TRUE, 150);
  121.     SetPort((WindowPtr) myWindow);
  122.     DrawGrowIcon (myWindow);
  123.  
  124.     srcPalette = NewPalette (numcolor, mycolors, pmCourteous, 0);
  125.     SetPalette ((WindowPtr) myWindow, srcPalette, TRUE);
  126.     
  127. /*______________________________________________________*/
  128. /*                    Set menus                         */
  129. /*______________________________________________________*/
  130.     mymenu0 = GetMenu(appleID);
  131.     AddResMenu(mymenu0, 'DRVR');
  132.     InsertMenu(mymenu0,0);
  133.     mymenu1 = newmenu(129,"File");
  134.     appendmenu(mymenu1,"Start;Quit");
  135.     InsertMenu(mymenu1,0);
  136.     mymenu2 = newmenu(130,"Edit");
  137.     InsertMenu(mymenu2,0);
  138.     DrawMenuBar();
  139.  
  140. /*______________________________________________________*/
  141. /*                  Init variables                      */
  142. /*______________________________________________________*/
  143.     DoneFlag = FALSE;
  144.     yieldTime = 0;
  145.     return;
  146. #endif
  147. }
  148.  
  149.  
  150. extern int real_main(int argc, char  *argv[]);
  151.  
  152. main(int argc, char  *argv[])
  153. {
  154.     MacInit();
  155.     real_main(argc, argv);
  156. }
  157.  
  158.  
  159. int
  160. getpid ()
  161.  
  162. {
  163.     return TickCount ();
  164. }
  165.  
  166.  
  167. #define SET_PREF(fFlag, thePref)                \
  168.     thePref = (prefs & fFlag) ? True : False;
  169.  
  170.  
  171.     static void
  172. InitMac (void)
  173.  
  174. {
  175.     Handle    hPrefs;
  176.     u_char    prefs = ePrefQuiet;
  177.     u_char    fTmpVideoC;
  178.  
  179.  
  180.     if ((hPrefs = GetResource (MACPREFS_RESTYPE, MACPREFS_RESID))
  181.             /* != (Handle) NULL */ &&
  182.         ResError () == noErr)
  183.     {
  184.         prefs = ** (u_char **) hPrefs;
  185.  
  186.         ReleaseResource (hPrefs);
  187.     }
  188.  
  189.     if (cmdKeyIsDown ())
  190.         prefs = DoMacPrefsDialog (prefs);
  191.  
  192.     SET_PREF (ePrefSmallVideoC    , fTmpVideoC);
  193.     SET_PREF (ePrefImageloop    , imageloop);
  194.     SET_PREF (ePrefShowDirectory, showdirectory);
  195.     SET_PREF (ePrefShowText        , showtext);
  196.     SET_PREF (ePrefPrintTheCodes, printthecodes);
  197.     SET_PREF (ePrefQuiet        , fQuiet);
  198.     SET_PREF (ePrefVerbose        , verbose);
  199.     SET_PREF (ePrefImVerbose    , imverbose);
  200.  
  201.     InitVideoC (fTmpVideoC);
  202. }
  203.